Full source code website bán hàng thương mại điện tử gần giống shopee
468.989 lượt xem;
1 <table height="28" cellSpacing="0" cellPadding="0" width="100%" border="0">
2 <tr align=center>
3 <td class="title" width="100%" height="17">
4 Danh mục sản phẩm : <b> <a href="./?act=category_m&page=<? echo $_REQUEST['page']; ?>&cat=<? echo $_REQUEST['cat']; ?>"><font color="#FFFFFF">Nhập
5 Mới</font></a><font color="#FFFFFF"> </font></b></td>
6 </tr>
7 </table>
8 <?
9
10 $MAXPAGE=20;
11
12 switch ($_GET['action'])
13 {
14 case 'del' :
15 $id = $_GET['id'];
16 $result = mysql_query("select cat from products where cat='".$id."'",$con);
17 if (mysql_num_rows($result)<=0) {
18 $sql = "delete from cat where id='".$id."'";
19 @$result = mysql_query($sql,$con);
20 if ($result) echo "<p align=center class='err'>Đã xóa thành công</p>";
21 else echo "<p align=center class='err'>Không thể xóa dữ liệu</p>";
22 } else {
23 echo "<p align=center class='err'>Đang có sản phẩm sử dụng. nên bạn không thể xóa</p>";
24 }
25
26 break;
27 }
28 ?>
29
30 <?
31 if (isset($_POST['ButDel'])) {
32 $cnt=0;
33 foreach ($_POST['chk'] as $id)
34 {
35 @$result = mysql_query("delete from cat where id='".$id."'",$con);
36 if ($result) $cnt++;
37 }
38 echo "<p align=center class='err'>Đã xóa ".$cnt." phần tử</p>";
39 }
40 ?>
41 <?
42 if (isset($_POST['active'])) {
43 $cnt=0;
44 foreach ($_POST['chk'] as $id)
45 {
46 @$result = mysql_query("update cat set status=0 where id='".$id."'",$con);
47 if ($result) $cnt++;
48 }
49 echo "<p align=center class='err'>Đã hiển thị ".$cnt." phần tử</p>";
50 }
51 ?>
52 <?
53 if (isset($_POST['un_active'])) {
54 $cnt=0;
55 foreach ($_POST['chk'] as $id)
56 {
57 @$result = mysql_query("update cat set status=1 where id='".$id."'",$con);
58 if ($result) $cnt++;
59 }
60 echo "<p align=center class='err'>Đã hủy hiển thị ".$cnt." phần tử</p>";
61 }
62 ?>
63 <?
64 $page = $_GET["page"];
65 $p=0;
66 if ($page!='') $p=$page;
67 $where="1=1";
68 if ($_REQUEST['cat']!='') $where="parent=".$_REQUEST['cat'];
69 ?>
70 <form method="POST" action="<? echo $_SERVER[PHP_SELF]; ?>" name="frmList">
71 <input type=hidden name="page" value="<? echo $page; ?>">
72 <?
73 function taotrang($sql,$link,$nitem,$itemcurrent)
74 { global $con;
75 $ret="";
76 $result = mysql_query($sql, $con) or die('Error' . mysql_error());
77 $value = mysql_fetch_array($result);
78 $plus = (($value['cnt'] % $nitem)>0);
79 for ($i=0;$i<($value[0] / $nitem) + plus;$i++)
80 {
81 if ($i<>$itemcurrent) $ret .= "<a href=\"".$link.$i."\" class=\"lslink\">".($i+1)."</a> ";
82 else $ret .= ($i+1)." ";
83 }
84 return $ret;
85 }
86 $pageindex=taotrang("select count(*) from cat where $where","./?act=category&cat=".$_REQUEST['cat']."&page=",$MAXPAGE,$page);
87 ?>
88
89 <table cellspacing="0" cellpadding="0" width="100%">
90 <tr>
91 <td class="smallfont" style="padding-top:10px;padding-bottom:10px">
92 <input type="button" value="+ Thêm mới" class="button" onclick="window.location='./?act=category_m&page=<? echo $_REQUEST['page']; ?>&cat=<? echo $_REQUEST['cat']; ?>'">
93 <input type="submit" value="Xóa Chọn" name="ButDel" onclick="return confirm('Bạn có chắc chắn muốn xoá ?');" class="button">
94 <input type="submit" value="Hiển thị" name="active" class="button">
95 <input type="submit" value="Hủy hiển thị" name="un_active" class="button">
96 </td>
97 <td height="30" align="right" class="smallfont">
98 </td>
99 </tr>
100 </table>
101
102 <table border="1" cellpadding="2" style="border-collapse: collapse" bordercolor="#C9C9C9" width="100%" id="AutoNumber1">
103 <tr>
104 <td align=center nowrap class="title"><input type="checkbox" name="chkall" onclick="chkallClick(this);"></td>
105 <td nowrap class="title"> </td>
106 <td nowrap class="title"> </td>
107 <td align="center" nowrap class="title"><b>Thứ tự</b></td>
108 <td align="center" nowrap class="title"><b>Tên danh mục</b></td>
109 <td align="center" nowrap class="title"><b>Hình</b></td>
110 <td align="center" nowrap class="title"><b>Thuộc danh mục</b></td>
111 <td align="center" nowrap class="title"><b>Không hiển thị</b></td>
112 </tr>
113 <?
114 $ms=GetListCat_admin(17);
115 $i=0;
116 foreach ($ms as $m)
117 {
118 $i++;
119 if ($i%2) $color="#d5d5d5"; else $color="#e5e5e5";
120 ?>
121 <tr bgcolor="<? echo $color;?>" class="table_a">
122 <td width="20" align="center" class="smallfont">
123 <input type="checkbox" name="chk[]" value="<? echo $m[0]; ?>"></td>
124 <td width="20" bgcolor="<? echo $color; ?>" class="smallfont">
125 <a href="./?act=category_m&cat=<? echo $_REQUEST['cat']; ?>&page=<? echo $_REQUEST['page']; ?>&id=<? echo $m[0]; ?>">
126 Sửa</a></td>
127 <td width="20" bgcolor="<? echo $color; ?>" class="smallfont">
128 <a href="./?act=category&action=del&page=<? echo $_REQUEST['page']; ?>&id=<? echo $m[0]; ?>">
129 Xoá</a></td>
130 <td width="20" bgcolor="<? echo $color; ?>" align="center" width="55" align="left" class="smallfont"><? echo $m[4]; ?></td>
131 <td bgcolor="<? echo $color; ?>" class="smallfont"><?php if($m[5]=='17'){?><font color="red"><b><? echo $m[1]; ?></b></font><?}else{?><? echo $m[1]; ?><?}?></td>
132 <td bgcolor="<? echo $color; ?>" class="smallfont"><? echo $m[2]; ?> </td>
133 <td width="80" bgcolor="<? echo $color; ?>" class="smallfont"><? echo $m[5]; ?> </td>
134 <td width="80" bgcolor="<? echo $color; ?>" class="smallfont"><? if($m[3]=='0') echo "Hiển thị"; else echo "Không hiển thị"; ?> </td>
135 </tr>
136 <?}
137 ?>
138 </table>
139 <table cellspacing="0" cellpadding="0" width="100%">
140 <tr>
141 <td class="smallfont" style="padding-top:10px;padding-bottom:10px">
142 <input type="button" value="+ Thêm mới" class="button" onclick="window.location='./?act=category_m&page=<? echo $_REQUEST['page']; ?>&cat=<? echo $_REQUEST['cat']; ?>'">
143 <input type="submit" value="Xóa Chọn" name="ButDel" onclick="return confirm('Bạn có chắc chắn muốn xoá ?');" class="button">
144 <input type="submit" value="Hiển thị" name="active" class="button">
145 <input type="submit" value="Hủy hiển thị" name="un_active" class="button">
146 </td>
147 <td height="30" align="right" class="smallfont">
148 </td>
149 </tr>
150 </table>
151 <input type="hidden" name="act" value="category">
152 </form>
153 <script language="JavaScript">
154 function chkallClick(o) {
155 var form = document.frmList;
156 for (var i = 0; i < form.elements.length; i++) {
157 if (form.elements[i].type == "checkbox" && form.elements[i].name!="chkall") {
158 form.elements[i].checked = document.frmList.chkall.checked;
159 }
160 }
161 }
162 </script>
2 <tr align=center>
3 <td class="title" width="100%" height="17">
4 Danh mục sản phẩm : <b> <a href="./?act=category_m&page=<? echo $_REQUEST['page']; ?>&cat=<? echo $_REQUEST['cat']; ?>"><font color="#FFFFFF">Nhập
5 Mới</font></a><font color="#FFFFFF"> </font></b></td>
6 </tr>
7 </table>
8 <?
9
10 $MAXPAGE=20;
11
12 switch ($_GET['action'])
13 {
14 case 'del' :
15 $id = $_GET['id'];
16 $result = mysql_query("select cat from products where cat='".$id."'",$con);
17 if (mysql_num_rows($result)<=0) {
18 $sql = "delete from cat where id='".$id."'";
19 @$result = mysql_query($sql,$con);
20 if ($result) echo "<p align=center class='err'>Đã xóa thành công</p>";
21 else echo "<p align=center class='err'>Không thể xóa dữ liệu</p>";
22 } else {
23 echo "<p align=center class='err'>Đang có sản phẩm sử dụng. nên bạn không thể xóa</p>";
24 }
25
26 break;
27 }
28 ?>
29
30 <?
31 if (isset($_POST['ButDel'])) {
32 $cnt=0;
33 foreach ($_POST['chk'] as $id)
34 {
35 @$result = mysql_query("delete from cat where id='".$id."'",$con);
36 if ($result) $cnt++;
37 }
38 echo "<p align=center class='err'>Đã xóa ".$cnt." phần tử</p>";
39 }
40 ?>
41 <?
42 if (isset($_POST['active'])) {
43 $cnt=0;
44 foreach ($_POST['chk'] as $id)
45 {
46 @$result = mysql_query("update cat set status=0 where id='".$id."'",$con);
47 if ($result) $cnt++;
48 }
49 echo "<p align=center class='err'>Đã hiển thị ".$cnt." phần tử</p>";
50 }
51 ?>
52 <?
53 if (isset($_POST['un_active'])) {
54 $cnt=0;
55 foreach ($_POST['chk'] as $id)
56 {
57 @$result = mysql_query("update cat set status=1 where id='".$id."'",$con);
58 if ($result) $cnt++;
59 }
60 echo "<p align=center class='err'>Đã hủy hiển thị ".$cnt." phần tử</p>";
61 }
62 ?>
63 <?
64 $page = $_GET["page"];
65 $p=0;
66 if ($page!='') $p=$page;
67 $where="1=1";
68 if ($_REQUEST['cat']!='') $where="parent=".$_REQUEST['cat'];
69 ?>
70 <form method="POST" action="<? echo $_SERVER[PHP_SELF]; ?>" name="frmList">
71 <input type=hidden name="page" value="<? echo $page; ?>">
72 <?
73 function taotrang($sql,$link,$nitem,$itemcurrent)
74 { global $con;
75 $ret="";
76 $result = mysql_query($sql, $con) or die('Error' . mysql_error());
77 $value = mysql_fetch_array($result);
78 $plus = (($value['cnt'] % $nitem)>0);
79 for ($i=0;$i<($value[0] / $nitem) + plus;$i++)
80 {
81 if ($i<>$itemcurrent) $ret .= "<a href=\"".$link.$i."\" class=\"lslink\">".($i+1)."</a> ";
82 else $ret .= ($i+1)." ";
83 }
84 return $ret;
85 }
86 $pageindex=taotrang("select count(*) from cat where $where","./?act=category&cat=".$_REQUEST['cat']."&page=",$MAXPAGE,$page);
87 ?>
88
89 <table cellspacing="0" cellpadding="0" width="100%">
90 <tr>
91 <td class="smallfont" style="padding-top:10px;padding-bottom:10px">
92 <input type="button" value="+ Thêm mới" class="button" onclick="window.location='./?act=category_m&page=<? echo $_REQUEST['page']; ?>&cat=<? echo $_REQUEST['cat']; ?>'">
93 <input type="submit" value="Xóa Chọn" name="ButDel" onclick="return confirm('Bạn có chắc chắn muốn xoá ?');" class="button">
94 <input type="submit" value="Hiển thị" name="active" class="button">
95 <input type="submit" value="Hủy hiển thị" name="un_active" class="button">
96 </td>
97 <td height="30" align="right" class="smallfont">
98 </td>
99 </tr>
100 </table>
101
102 <table border="1" cellpadding="2" style="border-collapse: collapse" bordercolor="#C9C9C9" width="100%" id="AutoNumber1">
103 <tr>
104 <td align=center nowrap class="title"><input type="checkbox" name="chkall" onclick="chkallClick(this);"></td>
105 <td nowrap class="title"> </td>
106 <td nowrap class="title"> </td>
107 <td align="center" nowrap class="title"><b>Thứ tự</b></td>
108 <td align="center" nowrap class="title"><b>Tên danh mục</b></td>
109 <td align="center" nowrap class="title"><b>Hình</b></td>
110 <td align="center" nowrap class="title"><b>Thuộc danh mục</b></td>
111 <td align="center" nowrap class="title"><b>Không hiển thị</b></td>
112 </tr>
113 <?
114 $ms=GetListCat_admin(17);
115 $i=0;
116 foreach ($ms as $m)
117 {
118 $i++;
119 if ($i%2) $color="#d5d5d5"; else $color="#e5e5e5";
120 ?>
121 <tr bgcolor="<? echo $color;?>" class="table_a">
122 <td width="20" align="center" class="smallfont">
123 <input type="checkbox" name="chk[]" value="<? echo $m[0]; ?>"></td>
124 <td width="20" bgcolor="<? echo $color; ?>" class="smallfont">
125 <a href="./?act=category_m&cat=<? echo $_REQUEST['cat']; ?>&page=<? echo $_REQUEST['page']; ?>&id=<? echo $m[0]; ?>">
126 Sửa</a></td>
127 <td width="20" bgcolor="<? echo $color; ?>" class="smallfont">
128 <a href="./?act=category&action=del&page=<? echo $_REQUEST['page']; ?>&id=<? echo $m[0]; ?>">
129 Xoá</a></td>
130 <td width="20" bgcolor="<? echo $color; ?>" align="center" width="55" align="left" class="smallfont"><? echo $m[4]; ?></td>
131 <td bgcolor="<? echo $color; ?>" class="smallfont"><?php if($m[5]=='17'){?><font color="red"><b><? echo $m[1]; ?></b></font><?}else{?><? echo $m[1]; ?><?}?></td>
132 <td bgcolor="<? echo $color; ?>" class="smallfont"><? echo $m[2]; ?> </td>
133 <td width="80" bgcolor="<? echo $color; ?>" class="smallfont"><? echo $m[5]; ?> </td>
134 <td width="80" bgcolor="<? echo $color; ?>" class="smallfont"><? if($m[3]=='0') echo "Hiển thị"; else echo "Không hiển thị"; ?> </td>
135 </tr>
136 <?}
137 ?>
138 </table>
139 <table cellspacing="0" cellpadding="0" width="100%">
140 <tr>
141 <td class="smallfont" style="padding-top:10px;padding-bottom:10px">
142 <input type="button" value="+ Thêm mới" class="button" onclick="window.location='./?act=category_m&page=<? echo $_REQUEST['page']; ?>&cat=<? echo $_REQUEST['cat']; ?>'">
143 <input type="submit" value="Xóa Chọn" name="ButDel" onclick="return confirm('Bạn có chắc chắn muốn xoá ?');" class="button">
144 <input type="submit" value="Hiển thị" name="active" class="button">
145 <input type="submit" value="Hủy hiển thị" name="un_active" class="button">
146 </td>
147 <td height="30" align="right" class="smallfont">
148 </td>
149 </tr>
150 </table>
151 <input type="hidden" name="act" value="category">
152 </form>
153 <script language="JavaScript">
154 function chkallClick(o) {
155 var form = document.frmList;
156 for (var i = 0; i < form.elements.length; i++) {
157 if (form.elements[i].type == "checkbox" && form.elements[i].name!="chkall") {
158 form.elements[i].checked = document.frmList.chkall.checked;
159 }
160 }
161 }
162 </script>